import 'package:app/common/app_theme.dart';
import 'package:app/common/colors.dart';
import 'package:app/common/tool.dart';
import 'package:app/components/base_scaffold_appbar.dart';
import 'package:app/pages/office_supplies_modules/office_detail_module/office_detail_model.dart';
import 'package:app/services/address.dart';
import 'package:app/services/dio_manager.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../utils/search_module.dart';
class OfficeDetailPage extends StatefulWidget {

   var id;
   OfficeDetailPage(this.id,{Key? key}) : super(key: key);

  @override
  State<OfficeDetailPage> createState() => _OfficeDetailPageState();
}

class _OfficeDetailPageState extends State<OfficeDetailPage> {
  
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    requestData();
  }

  OfficeDetaiModel? model;

  requestData()async{

    var json = await DioManager().kkRequest('${Address.officeUserRead}/${widget.id}',method: 'get');

    OfficeDetaiModel officeDetaiModel = OfficeDetaiModel.fromJson(json);

    model = officeDetaiModel;

    setState(() {

    });
  }

  
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: AppColor.bgColor,
      appBar: BaseAppBar(
        preferredSize: Size(Get.width,AppTool.appBarHEIGHT),
        child: Text('详情'),
      ),
      body: SafeArea(
        child: Column(
          children: [
            Expanded(child: ListView(
              children: [

                Container(
                  height: 45,
                  alignment: Alignment.centerLeft,
                  color: Colors.white,
                  padding: EdgeInsets.only(left: 15,right: 15),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text('物品名称',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                      Text('${model?.data?.officeName}',style: appThemeData.textTheme.bodyText1!.copyWith(fontSize: 15),),
                    ],
                  ),
                ),
                SizedBox(height: 1,),
                Container(
                  height: 45,
                  alignment: Alignment.centerLeft,
                  color: Colors.white,
                  padding: EdgeInsets.only(left: 15,right: 15),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text('总数量',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                      Text('${model?.data?.officeNumber}',style: appThemeData.textTheme.bodyText1!.copyWith(fontSize: 15),),
                    ],
                  ),
                ),
                SizedBox(height: 1,),
                Container(
                  height: 45,
                  alignment: Alignment.centerLeft,
                  color: Colors.white,
                  padding: EdgeInsets.only(left: 15,right: 15),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text('型号',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                      Text('${model?.data?.officeModel}',style: appThemeData.textTheme.bodyText1!.copyWith(fontSize: 15),),
                    ],
                  ),
                ),
                SizedBox(height: 1,),
                Container(
                  height: 45,
                  alignment: Alignment.centerLeft,
                  color: Colors.white,
                  padding: EdgeInsets.only(left: 15,right: 15),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text('物品类别',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                      Text('${model?.data?.officeType}',style: appThemeData.textTheme.bodyText1!.copyWith(fontSize: 15),),
                    ],
                  ),
                ),
                SizedBox(height: 1,),
                Container(
                  height: 45,
                  alignment: Alignment.centerLeft,
                  color: Colors.white,
                  padding: EdgeInsets.only(left: 15,right: 15),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text('使用人',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                      Text('${model?.data?.keeperName}',style: appThemeData.textTheme.bodyText1!.copyWith(fontSize: 15),),
                    ],
                  ),
                ),
                SizedBox(height: 1,),
                Container(
                  height: 45,
                  alignment: Alignment.centerLeft,
                  color: Colors.white,
                  padding: EdgeInsets.only(left: 15,right: 15),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text('数量',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                      Text('${model?.data?.number}',style: appThemeData.textTheme.bodyText1!.copyWith(fontSize: 15),),
                    ],
                  ),
                ),
                SizedBox(height: 1,),
                Container(
                  height: 45,
                  alignment: Alignment.centerLeft,
                  color: Colors.white,
                  padding: EdgeInsets.only(left: 15,right: 15),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text('总价值',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                      Text('${model?.data?.money}元',style: appThemeData.textTheme.bodyText1!.copyWith(fontSize: 15),),
                    ],
                  ),
                ),
                SizedBox(height: 1,),
                Container(
                  height: 45,
                  alignment: Alignment.centerLeft,
                  color: Colors.white,
                  padding: EdgeInsets.only(left: 15,right: 15),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text('使用日期',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                      Text('${model?.data?.date}',style: appThemeData.textTheme.bodyText1!.copyWith(fontSize: 15),),
                    ],
                  ),
                ),
                // Row(
                //   children: [
                //     CircleAvatar(
                //       backgroundImage: NetworkImage(
                //           '${Address.homeHost}${model?.data?.image}'
                //       ),
                //     ),
                //     SizedBox(width: 5,),
                //     Text('${model?.data?.operateName}'),
                //   ],
                // ),
              ],
            ),),
          ],
        ),
      ),
    );
  }
}
